package com.mooc.lib_common.model

import android.os.Parcel
import android.os.Parcelable
import com.chad.library.adapter.base.entity.MultiItemEntity
import java.io.Serializable

class FeedEntity() : MultiItemEntity,Parcelable {
    var id = 0
    var itemId: Long = 0
    override var itemType = 0
    var createTime: Long = 0
    var duration = 0.0
    var feeds_text: String? = null
    var authorId: Long = 0
    var activityIcon: String? = null
    var activityText: String? = null
    var width = 0
    var height = 0
    var url: String? = null
    var cover: String? = null
    var author : AuthorEntity?=null
    var topComment : CommentEntity ?= null
    var ugc : UGCEntity ?= null
    var comments : ArrayList<CommentEntity> = ArrayList()

    constructor(parcel: Parcel) : this() {
        id = parcel.readInt()
        itemId = parcel.readLong()
        itemType = parcel.readInt()
        createTime = parcel.readLong()
        duration = parcel.readDouble()
        feeds_text = parcel.readString()
        authorId = parcel.readLong()
        activityIcon = parcel.readString()
        activityText = parcel.readString()
        width = parcel.readInt()
        height = parcel.readInt()
        url = parcel.readString()
        cover = parcel.readString()
        author = parcel.readParcelable(AuthorEntity::class.java.classLoader)
        topComment = parcel.readParcelable(CommentEntity::class.java.classLoader)
        ugc = parcel.readParcelable(UGCEntity::class.java.classLoader)
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeLong(itemId)
        parcel.writeInt(itemType)
        parcel.writeLong(createTime)
        parcel.writeDouble(duration)
        parcel.writeString(feeds_text)
        parcel.writeLong(authorId)
        parcel.writeString(activityIcon)
        parcel.writeString(activityText)
        parcel.writeInt(width)
        parcel.writeInt(height)
        parcel.writeString(url)
        parcel.writeString(cover)
        parcel.writeParcelable(author, flags)
        parcel.writeParcelable(topComment, flags)
        parcel.writeParcelable(ugc, flags)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<FeedEntity> {
        override fun createFromParcel(parcel: Parcel): FeedEntity {
            return FeedEntity(parcel)
        }

        override fun newArray(size: Int): Array<FeedEntity?> {
            return arrayOfNulls(size)
        }
    }
}